package com.zetyun.tiger.sql.meta.tn;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrFormatter;
import com.zetyun.tiger.sql.pkm.GenSrPkmApp;

import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;

public class GenOdsTableApp {

    public static void main(String[] args) {

        StringBuilder sb = new StringBuilder("insert into ods_table values \n");

        String insertTemplate = "('{}','{}','{}',''),\n";

        List<String> otbs = FileUtil.readLines(Objects.requireNonNull(
                GenOdsTableApp.class.getResource("/ods_table.txt")), StandardCharsets.UTF_8);

        for (String name : otbs) {
            String[] arr = name.split("\t");
            String tbName = arr[0].trim();
            String tbCnName = arr[1].trim();
            String sysName = "CBUS";
            if (tbName.contains("_")) {
                sysName = "EBUS";
            }

            String item = StrFormatter.format(insertTemplate,tbName,tbCnName,sysName);
            sb.append(item);
//            System.out.println(tbName);
        }

        System.out.println(sb);
    }
}
